import { createRouter, createWebHistory } from 'vue-router';
import HomePage from '../components/HomePage.vue';
import SessionCoffee from '../components/SessionCoffee.vue';
import Espresso from '../components/Espresso.vue';
import ZeroCoffee from '../components/ZeroCoffee.vue';
import DirtyCoffee from '../components/DirtyCoffee.vue';
import ZeroDetail from '../components/ZeroDetail.vue';
import SessionDetail from '../components/SessionDetail.vue';
import DirtyDetail from '../components/DirtyDetail.vue';
import EspressoDetail from '../components/EspressoDetail.vue';
import SearchResults from '../components/SearchResults.vue';


// 定义路由
const routes = [
  {
    path: '/',
    name: 'HomePage',
    component: HomePage,
    redirect: '/SessionCoffee',
    children: [
      {
        path: 'SessionCoffee',
        component: SessionCoffee,
      },
      {
        path: 'Espresso',
        component: Espresso,
      },
      {
        path: 'ZeroCoffee',
        component: ZeroCoffee,

      },
      {
        path: 'Dirty',
        component: DirtyCoffee,
      },
      {
        path: '/Search/:searchQuery',
        name:'SearchResults',
        component: SearchResults,
      },
    ]
  },
  {
    path: '/ZeroDetail/:id', // 使用动态路由参数
    name: 'ZeroDetail',
    component: ZeroDetail,
  },
  {
    path: '/SessionDetail/:id', // 使用动态路由参数
    name: 'SessionDetail',
    component: SessionDetail,
  },
  {
    path: '/DirtyDetail/:id', // 使用动态路由参数
    name: 'DirtyDetail',
    component: DirtyDetail,
  },
  {
    path: '/EspressoDetail/:id', // 使用动态路由参数
    name: 'EspressoDetail',
    component: EspressoDetail,
  },
];

// 创建路由实例并传递历史模式
const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
